const fs = require("fs");
const path = require("path");

var pathFrom = path.join(__dirname,"/1.txt");//可读流
var pathTo = path.join(__dirname,"/2.txt");//可写流

var readStream = fs.createReadStream(pathFrom);
var writeStream = fs.createWriteStream(pathTo);

readStream.pipe(writeStream);//管道传输

writeStream.on("close",() => {
    var fileObj = fs.statSync(pathFrom);
    //赋予文件权限
    fs.chmodSync(pathTo,fileObj.mode);
})